using B.T.BasicData.Read.Api.Extensions;
using B.T.BasicData.Read.Api.Globalexceptionfilter;
using System.IO;

var builder = WebApplication.CreateBuilder(args).Inject();

//全局异常过滤器
builder.Services.AddControllers(x => x.Filters.Add<Globalexceptionfilter>());

//Nlog־
var logDir = Path.Combine(AppContext.BaseDirectory, "logs");
if (!Directory.Exists(logDir))
{
    Directory.CreateDirectory(logDir);
}

var app = builder.Build();
//
app.UseCors(x => x.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

// 鉴权
app.UseAuthentication();

app.UseAuthorization();

app.MapControllers();

app.Run();
